package communication;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.SocketException;

import exception.ParseException;

public class ClientConnectionHandle {

	private ConnectionHandle hndConnection;
	
	public ClientConnectionHandle(DataInputStream input, DataOutputStream output) {
		setHndConnection(new ConnectionHandle(input, output));
	}
	
	protected void disconnect() throws IOException {
		getHndConnection().close();
	}
	
	protected void send(Message msg) throws IOException {
		getHndConnection().send(msg);
		System.err.println("sent: " + msg + "\n");
	}
	
	protected String receive () throws ParseException, SocketException {
		String msg = getHndConnection().receive();
		System.err.println("received: " + msg + "\n");
		return msg;
	}

	public ConnectionHandle getHndConnection() {
		return hndConnection;
	}

	public void setHndConnection(ConnectionHandle hndConnection) {
		this.hndConnection = hndConnection;
	}
}
